﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace DeltagerListe
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //this.MyListbox.Items.Add("Test");
        }

        private void ListBox_SelectionChanged_1(object sender, SelectionChangedEventArgs e)
        {
            
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            FileStream fs = new FileStream(@"..\..\deltagerliste.csv", FileMode.Open, FileAccess.Read, FileShare.None);
            StreamReader sr = new StreamReader(fs);

            string[] tokens;
            string line;
            char[] separators = { ';' };

            while ((line = sr.ReadLine()) != null)
            {
                tokens = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                //FIX ME: Unicode? Formatting?
                this.MyListbox.Items.Add(String.Format("{0,-26}  {1,-15}  {2, -15}  {3,-25}", tokens));
            }

            this.LoadButton.IsEnabled = false;
        }


    }
}
